package cz.muni.fi.pa165.travelagency.dto;

import cz.muni.fi.pa165.travelagency.api.entities.ICustomer;
import cz.muni.fi.pa165.travelagency.api.entities.IOrder;
import java.util.List;
import java.util.Objects;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlAdapter;

/**
 *
 * @author Jan Novotny
 */
@XmlRootElement
public class CustomerDTO implements ICustomer {
    private static final long serialVersionUID = 5L;
    
    private Long id;
    private List<IOrder> orders;
    private String name;
    private String address;
    private String phoneNumber;

    public CustomerDTO() {
    }

    @Override
    public Long getId() {
        return id;
    }

    @Override
    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public List<IOrder> getOrders() {
        return orders;
    }

    @Override
    public void setOrders(List<IOrder> orders) {
        this.orders = orders;
    }

    @Override
    public String getName() {
        return name;
    }

    @Override
    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String getAddress() {
        return address;
    }

    @Override
    public void setAddress(String address) {
        this.address = address;
    }

    @Override
    public String getPhoneNumber() {
        return phoneNumber;
    }

    @Override
    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 73 * hash + Objects.hashCode(this.id);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final CustomerDTO other = (CustomerDTO) obj;
        if (!Objects.equals(this.id, other.id)) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "CustomerDTO{" + "id=" + id + ", orders=" + orders + ", name=" + name + ", address=" + address + ", phoneNumber=" + phoneNumber + '}';
    }
    
    static class Adapter extends XmlAdapter<CustomerDTO, ICustomer> {

        @Override
        public ICustomer unmarshal(CustomerDTO v) throws Exception {
            return v;
        }

        @Override
        public CustomerDTO marshal(ICustomer v) throws Exception {
            return (CustomerDTO) v;
        }
    }
}
